@extends('Admin.layout.layout')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>举报类型</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-12">
                                <a class="btn btn-sm btn-primary "  data-toggle="modal" data-target="#myModal">新增</a>
                            </div>
                        </div>
                        <table class="table table-striped table-bordered table-hover dataTable" id="editable">
                            <thead>
                                <tr>
                                    <th>举报类型</th>
                                    <th>举报类型描述</th>
                                    <th class="center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            @if(!empty($list))
                                @foreach($list as $value)
                                    <tr class="gradeX">
                                        <td>{{array_get($value ,'name')}}</td>
                                        <td>{{array_get($value,'content')}}</td>
                                        <td class="center">
                                            <a class="btn-xs btn-danger del_type" data-id="{{array_get($value,'id')}}">删除</a>
                                        </td>
                                    </tr>
                                @endforeach
                            @else
                                <tr class="no-records-found center"><td colspan="3">没有找到匹配的记录</td></tr>
                            @endif

                            </tbody>
                        </table>
                        <div class="row">
                            @include('Admin.common.paginate', ['page' => $page])
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    新增分类
                </h4>
            </div>
            <form class="form-horizontal m-t" action="" method="post" id="signupForm">
                {{csrf_field()}}
            <div class="modal-body">
                <div class="form-group">
                    <label class="col-sm-3 control-label">分类名称：</label>
                    <div class="col-sm-9">
                        <input id="writtenWords" name="name" class="form-control" type="text" placeholder="文字标识">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">分类描述：</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" name="content" rows="3"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary" id="btn_submit">
                    确定
                </button>
                <button type="button" class="btn btn-default"
                        data-dismiss="modal" >取消
                </button>
            </div>
            </form>
        </div>
    </div>
</div>

    <script src="{{asset('js/plugins/layer/laydate/laydate.js')}}"></script>
    <script src="{{asset('js/plugins/layer/layer.min.js')}}"></script>

    <script>
        $(document).ready(function () {
            //删除
            $('.del_type').click(function(){
                var type_id = $(this).attr('data-id');
                layer.confirm('是否删除举报类型？', {
                    btn: ['确认', '取消'] //可以无限个按钮
                }, function (index) {
                    $.ajax({
                        url: '/foradmin/report/type/del',
                        type: 'post',
                        dataType: 'json',
                        data: {'id': type_id},
                        success: function (data) {
                            if (0 == data.code) {
                                layer.alert("删除成功", {
                                    icon: 1
                                }, function () {
                                    location.reload();
                                });
                            } else {
                                layer.alert("删除失败", {
                                    icon: 2
                                });
                            }
                        }
                    });
                }, function (index, layero) {
                    layer.close(index);
                });
            })
        })
    </script>
@endsection
